<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>教师仪表盘 - 教学管理系统</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 0;
        }

        .container {
            display: flex;
            min-height: 100vh;
        }

        .sidebar {
            width: 250px;
            background-color: #2c3e50;
            color: white;
            padding-top: 20px;
        }

        .sidebar-header {
            padding: 0 20px 20px;
            border-bottom: 1px solid #3c5166;
        }

        .sidebar-header h2 {
            margin: 0;
            font-size: 20px;
        }

        .user-info {
            margin-top: 10px;
            font-size: 14px;
            opacity: 0.8;
        }

        .menu {
            list-style: none;
            padding: 0;
            margin: 20px 0;
        }

        .menu li {
            padding: 12px 20px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .menu li:hover {
            background-color: #3c5166;
        }

        .menu li.active {
            background-color: #3498db;
        }

        .menu a {
            color: white;
            text-decoration: none;
            display: block;
        }

        .content {
            flex: 1;
            padding: 20px;
        }

        .content-header {
            margin-bottom: 30px;
        }

        .content-header h1 {
            margin: 0;
            color: #333;
            font-size: 24px;
        }

        .dashboard-cards {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .card {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 20px;
        }

        .card h2 {
            margin-top: 0;
            color: #333;
            font-size: 18px;
        }

        .card p {
            color: #666;
        }

        .card-stat {
            font-size: 24px;
            font-weight: bold;
            color: #3498db;
            margin-top: 10px;
        }

        .course-list {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 20px;
        }

        .course-list h2 {
            margin-top: 0;
            color: #333;
            font-size: 18px;
            margin-bottom: 20px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        table th,
        table td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }

        table th {
            background-color: #f8f9fa;
            color: #333;
            font-weight: 600;
        }

        table tr:hover {
            background-color: #f5f5f5;
        }

        .btn {
            display: inline-block;
            padding: 6px 12px;
            background-color: #3498db;
            color: white;
            border-radius: 4px;
            text-decoration: none;
            font-size: 14px;
        }

        .btn:hover {
            background-color: #2980b9;
        }

        .logout {
            margin-top: auto;
            padding: 20px;
        }

        .logout a {
            color: #e74c3c;
            text-decoration: none;
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="sidebar">
            <div class="sidebar-header">
                <h2>教学管理系统</h2>
                <div class="user-info" th:if="${session.user}">
                    <span th:text="${session.user.username}">teacher1</span> - 教师
                </div>
            </div>
            <ul class="menu">
                <li class="active"><a href="/teacher/dashboard">我的概览</a></li>
                <li><a href="/teacher/courses">我的课程</a></li>
                <li><a href="/teacher/students">我的学生</a></li>
                <li><a href="/teacher/grades">成绩管理</a></li>
                <li><a href="/teacher/profile">个人信息</a></li>
            </ul>
            <div class="logout">
                <a href="/logout">退出登录</a>
            </div>
        </div>

        <div class="content">
            <div class="content-header">
                <h1>我的教学概览</h1>
            </div>

            <div class="dashboard-cards">
                <div class="card">
                    <h2>我的课程数</h2>
                    <div class="card-stat" th:text="${overview != null ? overview.courseCount : '0'}">2</div>
                    <p>当前学期我负责的课程数量</p>
                </div>
                <div class="card">
                    <h2>我的学生数</h2>
                    <div class="card-stat" th:text="${overview != null ? overview.studentCount : '0'}">35</div>
                    <p>所有课程的学生总数</p>
                </div>
                <div class="card">
                    <h2>本周课时数</h2>
                    <div class="card-stat" th:text="${overview != null ? overview.weeklyHours : '0'}">12</div>
                    <p>本周需要上课的总课时</p>
                </div>
            </div>

            <div class="course-list">
                <h2>当前学期课程</h2>
                <table>
                    <thead>
                        <tr>
                            <th>课程编号</th>
                            <th>课程名称</th>
                            <th>学分</th>
                            <th>教室</th>
                            <th>学生数</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr th:if="${courses == null || courses.isEmpty()}">
                            <td colspan="6" style="text-align: center;">暂无课程数据</td>
                        </tr>
                        <tr th:each="course : ${courses}">
                            <td th:text="${course.courseId}">CS101</td>
                            <td th:text="${course.name}">计算机导论</td>
                            <td th:text="${course.credit}">4</td>
                            <td th:text="${course.classroom != null ? course.classroom.building : '未分配'}">A101</td>
                            <td th:text="${course.studentCount != null ? course.studentCount : '0'}">20</td>
                            <td><a th:href="@{'/teacher/course/' + ${course.courseId}}" class="btn">管理</a></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            console.log("教师仪表盘页面加载完成");
        });
    </script>
</body>

</html>